<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台登录页</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="/tpblog/public/static/admin/css/font.css">
	<link rel="stylesheet" href="/tpblog/public/static/admin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/tpblog/public/static/admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/tpblog/public/static/admin/js/xadmin.js"></script>

</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">后台管理登录</div>
        <div id="darkbannerwrap"></div>
        <form method="post" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text"  class="layui-input" >
            <hr class="hr15">
            <input name="password" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="登录" id="login" style="width:100%;" type="submit">
            <hr class="hr20" >
            <div style="text-align: center;">
                <a href="{:url('admin/index/register')}">注册账号</a>
            </div>
        </form>
    </div>

    <script>
        $(function  () {
           $('#login').click(function () {
               $.ajax({
                   url:"{:url('admin/index/login')}",
                   type:"post",
                   data:$('form').serialize(),
                   dataType:'json',
                   success:function (data) {
                       console.log(data)
                       if(data.code==1){
                           layer.msg(data.msg,{
                               icon:6,
                               time:2000
                           },function () {
                                location.href=data.url;
                           })
                       }else{
                           layer.open({
                               title:'登录失败',
                               content:data.msg,
                               icon:5,
                               anim:6
                           })
                       }
                   }
               });
               return false;
           })
        })


    </script>
</body>
</html>